package com.haoshuang.zhouzhoubang.ui.page.mine.invite.record

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.SpreadServiceRecordBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class InviteTeamMemberRecordChildViewModel : BaseViewModel() {
    /**
     * 邀请记录
     */
    val spreadServiceRecordData = StatefulMutableLiveData<MutableList<SpreadServiceRecordBean>>()
    fun spreadServiceRecord(
        type: Int,
        time_type: Int,
        start_time: String,
        end_time: String,
        page: Int
    ) = netRequest {
        start { spreadServiceRecordData.value = StateData.Loading }
        request { ApiRepo.spreadServiceRecord(type, time_type, start_time, end_time, page) }
        success { spreadServiceRecordData.value = StateData.Success(it.data) }
        error { code, msg ->
            spreadServiceRecordData.value = StateData.Error(code, msg)
        }
    }
}